package apoc.core.client.gui.hud;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import org.lwjgl.opengl.GL11;

import java.util.LinkedList;

public class OverlayHandler
{

    private LinkedList<HUDComponent> components;

    public OverlayHandler()
    {
        components = new LinkedList<HUDComponent>();
    }

    public void addComponent(HUDComponent component)
    {
        components.add(component);
    }

    @SubscribeEvent
    public void onOverlayRendered(RenderGameOverlayEvent.Post event)
    {
        if (event.isCancelable() || event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE)
        {
            return;
        }

        for (HUDComponent component : components)
        {
            ScaledResolution resolution = event.resolution;
            component.update(resolution, event.mouseX, event.mouseY);
            component.draw(event.mouseX, event.mouseY);
        }
    }

}
